package com.atheima.reggie.common;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;

public class ValidateUtil {



    public static boolean isNotEmpty(String str){
        return !isEmpty(str);
    }

    public static boolean isEmpty(String str){
        return str == null || str.length() == 0;
    }

    public static <T> boolean notEmpty(Collection<T> collection){
        if(collection != null){
            Iterator<T> iterator = collection.iterator();
            if(iterator != null){
                while(iterator.hasNext()){
                    Object next = iterator.next();
                    if(next != null){
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static <T> boolean isEmpty(Collection<T> collection){
        return !notEmpty(collection);
    }

    public static <T> boolean notEmpty(Map<T, T> map){
        return map != null && !map.isEmpty();
    }

    public static <T> boolean isEmpty(Map<T, T> map){
        return !notEmpty(map);
    }

}
